{extend name="common@base/common" /}

{block name="style"}
<link href="__CSS__/main.min.css" rel="stylesheet" type="text/css"/>
{/block}

{block name="body"}
<div class="container">
  <ol class="breadcrumb">
      <li><a href="{:url('index/index')}">演示首页</a></li>
      <li>分页器</li>
  </ol>
<section class="demo-section">
<div id="pageContent">

<article><p>分页器是一个使用 JavaScript 增强的分页组件，不同于传统的 <a href="#component/pager">组件-&gt;分页条</a>，分页器只需要给定一些参数即可创建丰富外观的分页指示组件。</p></article>




<section><header><h3>综合示例</h3></header><article><p>为一个空的 <code>&lt;ul class="pager"&gt;</code> 元素添加 <code>[data-ride="pager"]</code> 属性来启用分页器，通过 <code>data-page</code>、<code>data-rec-total</code>、<code>data-rec-per-page</code> 来分别指定初始状态时当前页数、总记录数和每页记录数。</p><div class="example">
  <ul class="pager" data-ride="pager" data-page="2" data-rec-total="89"><li class="pager-item-left"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-step-backward"></i></a></li><li><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-double-angle-left"></i></a></li><li><a title="第 1 页" class="pager-item" data-page="1" href="#page=1">1</a></li><li class="active disabled"><a title="第 2 页" class="pager-item" data-page="2" href="#page=2">2</a></li><li><a title="第 3 页" class="pager-item" data-page="3" href="#page=3">3</a></li><li><a title="第 4 页" class="pager-item" data-page="4" href="#page=4">4</a></li><li><a title="第 5 页" class="pager-item" data-page="5" href="#page=5">5</a></li><li><a title="第 6 页" class="pager-item" data-page="6" href="#page=6">6</a></li><li><a title="第 7 页" class="pager-item" data-page="7" href="#page=7">7</a></li><li><a title="第 8 页" class="pager-item" data-page="8" href="#page=8">8</a></li><li><a title="第 9 页" class="pager-item" data-page="9" href="#page=9">9</a></li><li><a title="第 3 页" class="pager-item" data-page="3" href="#page=3"><i class="icon icon-double-angle-right"></i></a></li><li class="pager-item-right"><a title="第 9 页" class="pager-item" data-page="9" href="#page=9"><i class="icon icon-step-forward"></i></a></li><li><div class="pager-label">第 <strong>2</strong>/<strong>9</strong> 页</div></li><li><div class="pager-label">第 <strong>11</strong> ~ <strong>20</strong> 项</div></li><li><div class="pager-label">共 <strong>89</strong> 项</div></li></ul>
</div><pre class="prettyprint prettyprinted" style=""><code class="lang-html"><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"89"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre></article></section>













<section><header><h3>界面元素</h3></header><article><p>分页器内置了多种类型的界面元素，只需要使用初始化选项 <code>elements</code> 指定所需的元素名称和顺序即可。</p><p>所有可用的界面元素包括：</p><div class="table-responsive"><table class="table table-bordered" id="pagerPreviewTable">
  <thead>
    <tr>
      <th style="width: 120px">元素名称</th>
      <th style="width: 180px">说明</th>
      <th>预览和源码</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>prev</code></td>
      <td>显示上一页文字按钮</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="prev" data-rec-total="100" data-page="2"><li class="pager-item-left pager-item-right"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1">上一页</a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"prev"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>next</code></td>
      <td>显示下一页文字按钮</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="next" data-rec-total="100"><li class="pager-item-left pager-item-right"><a title="第 2 页" class="pager-item" data-page="2" href="#page=2">下一页</a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"next"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>prev_icon</code></td>
      <td>显示上一页图标按钮，可以通过 <code>prevIcon</code> 选项自定义按钮图标</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="prev_icon" data-rec-total="100" data-page="2"><li class="pager-item-left pager-item-right"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-double-angle-left"></i></a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"prev_icon"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>next_icon</code></td>
      <td>显示下一页图标按钮，可以通过 <code>nextIcon</code> 选项自定义按钮图标</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="next_icon" data-rec-total="100"><li class="pager-item-left pager-item-right"><a title="第 2 页" class="pager-item" data-page="2" href="#page=2"><i class="icon icon-double-angle-right"></i></a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"next_icon"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>first</code></td>
      <td>显示第一页文字按钮</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="first" data-rec-total="100" data-page="2"><li class="pager-item-left pager-item-right"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1">第一页</a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"first"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>last</code></td>
      <td>显示最后一页文字按钮</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="last" data-rec-total="100"><li class="pager-item-left pager-item-right"><a title="第 10 页" class="pager-item" data-page="10" href="#page=10">最后一页</a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"last"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>first_icon</code></td>
      <td>显示上一页图标按钮，可以通过 <code>firstIcon</code> 选项自定义按钮图标</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="first_icon" data-rec-total="100" data-page="2"><li class="pager-item-left pager-item-right"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-step-backward"></i></a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"first_icon"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>last_icon</code></td>
      <td>显示下一页图标按钮，可以通过 <code>lastIcon</code> 选项自定义按钮图标</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="last_icon" data-rec-total="100"><li class="pager-item-left pager-item-right"><a title="第 10 页" class="pager-item" data-page="10" href="#page=10"><i class="icon icon-step-forward"></i></a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"last_icon"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"100"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>nav</code> 或 <code>pages</code></td>
      <td>显示页码导航，可以通过 <code>maxNavCount</code> 选项自定义导航上的最多按钮数目</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="nav" data-rec-total="1000" data-max-nav-count="6"><li class="active disabled pager-item-left"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1">1</a></li><li><a title="第 2 页" class="pager-item" data-page="2" href="#page=2">2</a></li><li><a title="第 3 页" class="pager-item" data-page="3" href="#page=3">3</a></li><li><a title="第 4 页" class="pager-item" data-page="4" href="#page=4">4</a></li><li class="disabled"><a title="第 0 页" class="pager-item" data-page="0" href="###"><i class="icon icon-ellipsis-h"></i></a></li><li class="pager-item-right"><a title="第 100 页" class="pager-item" data-page="100" href="#page=100">100</a></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"nav"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="pln"> </span><span class="atn">data-max-nav-count</span><span class="pun">=</span><span class="atv">"6"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>goto</code></td>
      <td>显示页面转向输入组</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="goto" data-rec-total="1000" data-max-nav-count="6"><li><div class="input-group pager-goto" style="width: 93px"><input value="1" type="number" min="1" max="100" placeholder="1" class="form-control pager-goto-input"><span class="input-group-btn"><button class="btn pager-goto-btn" type="button">跳转</button></span></div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"goto"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="pln"> </span><span class="atn">data-max-nav-count</span><span class="pun">=</span><span class="atv">"6"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>size_menu</code></td>
      <td>显示每页数目下拉菜单，下拉菜单选项可以通过 <code>pageSizeOptions</code> 选项自定义，通过 <code>menuDirection</code> 来自定义菜单弹出方向</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="size_menu" data-rec-total="1000" data-max-nav-count="6"><li><div class="btn-group pager-size-menu dropdown"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown">每页 <strong>10</strong> 项 <span class="caret"></span></button><ul class="dropdown-menu"><li class="active"><a href="###" data-size="10">10</a></li><li><a href="###" data-size="20">20</a></li><li><a href="###" data-size="30">30</a></li><li><a href="###" data-size="50">50</a></li><li><a href="###" data-size="100">100</a></li></ul></div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"size_menu"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="pln"> </span><span class="atn">data-max-nav-count</span><span class="pun">=</span><span class="atv">"6"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre></td>
    </tr>
    <tr>
      <td><code>total_text</code></td>
      <td>显示总记录数目文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="total_text" data-rec-total="1000"><li><div class="pager-label">共 <strong>1000</strong> 项</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"total_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>page_text</code></td>
      <td>显示当前页码文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="page_text" data-rec-total="1000"><li><div class="pager-label">第 <strong>1</strong> 页</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"page_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>total_page_text</code></td>
      <td>显示总页数文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="total_page_text" data-rec-total="1000"><li><div class="pager-label">共 <strong>100</strong> 页</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"total_page_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>page_of_total_text</code></td>
      <td>显示页码和总页码文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="page_of_total_text" data-rec-total="1000"><li><div class="pager-label">第 <strong>1</strong>/<strong>100</strong> 页</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"page_of_total_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>items_range_text</code></td>
      <td>显示记录序号范围文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="items_range_text" data-rec-total="1000"><li><div class="pager-label">第 <strong>1</strong> ~ <strong>10</strong> 项</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"items_range_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>page_size_text</code></td>
      <td>显示每页记录数目文本</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="page_size_text" data-rec-total="1000"><li><div class="pager-label">每页 <strong>10</strong> 项</div></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"page_size_text"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
    <tr>
      <td><code>space</code> 或 <code>|</code></td>
      <td>显示一个空白间隙作为元素间的分隔</td>
      <td>
        <ul class="pager" data-ride="pager" data-elements="space" data-rec-total="1000"><li class="space"></li></ul>
        <pre class="prettyprint prettyprinted" style=""><code><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"space"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"1000"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre>
      </td>
    </tr>
  </tbody>
</table></div><p>以上所有界面元素可以自由组合使用。</p><h4>简单按钮组合示例</h4><div class="example">
  <ul class="pager" data-ride="pager" data-page="2" data-rec-total="89" data-max-nav-count="4" data-elements="prev_icon,nav,next_icon"><li class="pager-item-left"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-double-angle-left"></i></a></li><li><a title="第 1 页" class="pager-item" data-page="1" href="#page=1">1</a></li><li class="disabled"><a title="第 0 页" class="pager-item" data-page="0" href="###"><i class="icon icon-ellipsis-h"></i></a></li><li class="active disabled"><a title="第 2 页" class="pager-item" data-page="2" href="#page=2">2</a></li><li class="disabled"><a title="第 0 页" class="pager-item" data-page="0" href="###"><i class="icon icon-ellipsis-h"></i></a></li><li><a title="第 9 页" class="pager-item" data-page="9" href="#page=9">9</a></li><li class="pager-item-right"><a title="第 3 页" class="pager-item" data-page="3" href="#page=3"><i class="icon icon-double-angle-right"></i></a></li></ul>
</div><pre class="prettyprint prettyprinted" style=""><code class="lang-html"><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"89"</span><span class="pln"> </span><span class="atn">data-max-nav-count</span><span class="pun">=</span><span class="atv">"4"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"prev_icon,nav,next_icon"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre><h4>简单翻页和页码信息组合示例</h4><div class="example">
  <ul class="pager" data-ride="pager" data-page="2" data-rec-total="89" data-max-nav-count="4" data-elements="prev_icon,page_of_total_text,next_icon"><li class="pager-item-left pager-item-right"><a title="第 1 页" class="pager-item" data-page="1" href="#page=1"><i class="icon icon-double-angle-left"></i></a></li><li><div class="pager-label">第 <strong>2</strong>/<strong>9</strong> 页</div></li><li class="pager-item-left pager-item-right"><a title="第 3 页" class="pager-item" data-page="3" href="#page=3"><i class="icon icon-double-angle-right"></i></a></li></ul>
</div><pre class="prettyprint prettyprinted" style=""><code class="lang-html"><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"89"</span><span class="pln"> </span><span class="atn">data-max-nav-count</span><span class="pun">=</span><span class="atv">"4"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"prev_icon,page_of_total_text,next_icon"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre></article></section>






<section><header><h3>选项</h3></header><article><p>选项用于初始化分页器。为一个空的 <code>&lt;ul class="pager"&gt;</code> 元素添加 <code>[data-ride="pager"]</code> 属性来自动进行初始化，通过 <code>[data-*]</code> 属性的形式来指定初始化选项。</p><p>同时也可以随时进行手动初始化。</p><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="com">// 手动进行初始化</span><span class="pln">
$</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">pager</span><span class="pun">({</span><span class="pln">
    page</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln">
    recTotal</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100</span><span class="pln">
</span><span class="pun">});</span></code></pre><p>所有可用的初始化选项包括：</p><div class="table-responsive"><table class="table table-bordered">
  <thead>
    <tr>
      <th style="width: 140px">选项</th>
      <th style="width: 150px">名称</th>
      <th style="width: 150px">可用值</th>
      <th>说明</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>page</code></td>
      <td>初始状态的当前页码</td>
      <td>默认为 <code>1</code></td>
      <td>大于等于 <code>1</code> 小于等于总页数的整数，输入其他内容将自动转换为符合范围的整数。</td>
    </tr>
    <tr>
      <td><code>recTotal</code></td>
      <td>总记录数目</td>
      <td>默认为 <code>0</code></td>
      <td>大于等于 <code>0</code> 的整数。</td>
    </tr>
    <tr>
      <td><code>recPerPage</code></td>
      <td>每页记录数</td>
      <td>默认为 <code>10</code></td>
      <td>大于等于 <code>1</code> 的整数。</td>
    </tr>
    <tr>
      <td><code>elements</code></td>
      <td>界面元素排列定义</td>
      <td>默认为 <code>['first_icon', 'prev_icon', 'pages', 'next_icon', 'last_icon', 'page_of_total_text', 'items_range_text', 'total_text']</code></td>
      <td>允许使用字符串数组或者逗号分割的字符串来指定元素名称排列定义，元素名称及对应外观参见上文“界面元素”内容。</td>
    </tr>
    <tr>
      <td><code>elementCreator</code></td>
      <td>元素创建器</td>
      <td>默认为 <code>null</code></td>
      <td>可以设置一个函数或者一个对象，具体用法参见下文“自定义”内容。</td>
    </tr>
    <tr>
      <td><code>linkCreator</code></td>
      <td>导航链接生成器</td>
      <td>默认为 <code>'#page={page}'</code></td>
      <td>可以设置一个字符串作为链接模板，例如默认值 <code>'#page={page}'</code>（当页码为 <code>1</code> 时生成的链接为 <code>'#page=1'</code>）；或者使用一个回调函数 <code>function(page, pager)</code> 来动态返回链接地址，参数 <code>page</code> 为当前页码，参数 <code>pager</code> 为其他页码信息。</td>
    </tr>
    <tr>
      <td><code>maxNavCount</code></td>
      <td>页码导航最大条目数目</td>
      <td>默认为 <code>10</code></td>
      <td>大于等于 <code>1</code> 的整数。</td>
    </tr>
    <tr>
      <td><code>prevIcon</code></td>
      <td>上一页图标按钮使用的图标</td>
      <td>默认为 <code>icon-double-angle-left</code></td>
      <td>可以使用 <a href="#control/icon">控件-&gt;图标</a> 中的图标。</td>
    </tr>
    <tr>
      <td><code>nextIcon</code></td>
      <td>上一页图标按钮使用的图标</td>
      <td>默认为 <code>icon-double-angle-right</code></td>
      <td>可以使用 <a href="#control/icon">控件-&gt;图标</a> 中的图标。</td>
    </tr>
    <tr>
      <td><code>firstIcon</code></td>
      <td>第一页图标按钮使用的图标</td>
      <td>默认为 <code>icon-step-backward</code></td>
      <td>可以使用 <a href="#control/icon">控件-&gt;图标</a> 中的图标。</td>
    </tr>
    <tr>
      <td><code>lastIcon</code></td>
      <td>最后一页图标按钮使用的图标</td>
      <td>默认为 <code>icon-step-forward</code></td>
      <td>可以使用 <a href="#control/icon">控件-&gt;图标</a> 中的图标。</td>
    </tr>
    <tr>
      <td><code>menuDirection</code></td>
      <td>每页数目选择菜单方向</td>
      <td>默认为 <code>'dropdown'</code></td>
      <td>
        <ul>
          <li><code>dropdown</code>：菜单向下弹出；</li>
          <li><code>dropup</code>：菜单向上弹出；</li>
        </ul>
      </td>
    </tr>
    <tr>
      <td><code>pageSizeOptions</code></td>
      <td>每页数目菜单选项</td>
      <td>默认为 <code>[10, 20, 30, 50, 100]</code></td>
      <td>使用一个整数数组来指定允许用户可以选择的每页数目。</td>
    </tr>
    <tr>
      <td><code>navEllipsisItem</code></td>
      <td>导航省略项内容</td>
      <td>默认为 <code>'&lt;i class="icon icon-ellipsis-h"&gt;&lt;/i&gt;'</code></td>
      <td>可以使用 HTML 代码。</td>
    </tr>
    <tr>
      <td><code>lang</code></td>
      <td>当前界面语言</td>
      <td>默认为 <code>'zh_cn'</code></td>
      <td>
        <p>所以可用的选项包括：</p>
        <ul>
          <li><code>zh_cn</code>：使用中文简体界面；</li>
          <li><code>zh_tw</code>：使用中文繁体界面；</li>
          <li><code>en</code>：使用英文界面；</li>
          <li>
            <p>或者指定一个对象来自定义语言文本，例如：</p>
            <pre class="prettyprint prettyprinted" style=""><code><span class="pun">{</span><span class="pln">
    prev</span><span class="pun">:</span><span class="pln"> </span><span class="str">'上一页'</span><span class="pun">,</span><span class="pln">
    </span><span class="kwd">next</span><span class="pun">:</span><span class="pln"> </span><span class="str">'下一页'</span><span class="pun">,</span><span class="pln">
    first</span><span class="pun">:</span><span class="pln"> </span><span class="str">'第一页'</span><span class="pun">,</span><span class="pln">
    </span><span class="kwd">last</span><span class="pun">:</span><span class="pln"> </span><span class="str">'最后一页'</span><span class="pun">,</span><span class="pln">
    </span><span class="kwd">goto</span><span class="pun">:</span><span class="pln"> </span><span class="str">'跳转'</span><span class="pun">,</span><span class="pln">
    pageOf</span><span class="pun">:</span><span class="pln"> </span><span class="str">'第 </span><strong><span class="str">{page}</span></strong><span class="str"> 页'</span><span class="pun">,</span><span class="pln">
    totalPage</span><span class="pun">:</span><span class="pln"> </span><span class="str">'共 </span><strong><span class="str">{totalPage}</span></strong><span class="str"> 页'</span><span class="pun">,</span><span class="pln">
    totalCount</span><span class="pun">:</span><span class="pln"> </span><span class="str">'共 </span><strong><span class="str">{recTotal}</span></strong><span class="str"> 项'</span><span class="pun">,</span><span class="pln">
    pageSize</span><span class="pun">:</span><span class="pln"> </span><span class="str">'每页 </span><strong><span class="str">{recPerPage}</span></strong><span class="str"> 项'</span><span class="pun">,</span><span class="pln">
    itemsRange</span><span class="pun">:</span><span class="pln"> </span><span class="str">'第 </span><strong><span class="str">{start}</span></strong><span class="str"> ~ </span><strong><span class="str">{end}</span></strong><span class="str"> 项'</span><span class="pun">,</span><span class="pln">
    pageOfTotal</span><span class="pun">:</span><span class="pln"> </span><span class="str">'第 </span><strong><span class="str">{page}</span></strong><span class="str">/</span><strong><span class="str">{totalPage}</span></strong><span class="str"> 页'</span><span class="pln">
</span><span class="pun">}</span></code></pre>
          </li>
        </ul>
      </td>
    </tr>
    <tr>
      <td><code>onPageChange</code></td>
      <td>当页码变更时的回调函数</td>
      <td>默认为 <code>null</code></td>
      <td>具体用法参见下文“监听页码变更”内容。</td>
    </tr>
    <tr>
      <td><code>onRender</code></td>
      <td>当分页器界面更新并渲染完毕时调用</td>
      <td>默认为 <code>null</code></td>
      <td>该事件回调函数包含一个参数 <code>staet</code>，为当前最新的页码状态信息对象。</td>
    </tr>
  </tbody>
</table></div></article></section>




<section><header><h3>获取页码状态信息</h3></header><article><p>直接访问分页器对象实例的 <code>state</code> 属性对象即可。该对象包含如下属性：</p><ul>
<li><code>page</code>：当前页码；</li>
<li><code>recPerPage</code>：每页记录数目；</li>
<li><code>recTotal</code>：记录总数；</li>
<li><code>totalPage</code>：总页数；</li>
<li><code>pageRecCount</code>：当前页记录数；</li>
<li><code>skip</code>：已略过的记录数目；</li>
<li><code>start</code>：当前页第一条记录序号；</li>
<li><code>end</code>：当前页最后一条记录序号；</li>
<li><code>prev</code>：上一页页码，如果没有上一页则此属性值为 <code>0</code>；</li>
<li><code>next</code>：下一页页码，如果没有下一页则此属性值为 <code>0</code>。</li>
</ul><p>下面以获取当前页记录数目为例：</p><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="com">// 获取分页器实例对象</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> myPager </span><span class="pun">=</span><span class="pln"> $</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">data</span><span class="pun">(</span><span class="str">'zui.pager'</span><span class="pun">);</span><span class="pln">

</span><span class="com">// 获取页码状态信息对象</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> pageState </span><span class="pun">=</span><span class="pln"> myPager</span><span class="pun">.</span><span class="pln">state</span><span class="pun">;</span><span class="pln">

</span><span class="com">// 打印当前页记录数目</span><span class="pln">
console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="str">'当前页记录数目为'</span><span class="pun">,</span><span class="pln"> pageState</span><span class="pun">.</span><span class="pln">pageRecCount</span><span class="pun">);</span></code></pre></article></section>




<section><header><h3>监听页码变更</h3></header><article><p>使用 <code>onPageChange</code> 事件可以监听页码状态变更事件。该事件回调函数参数定义如下：</p><ul>
<li><code>state</code>: 新的页码状态对象；</li>
<li><code>oldState</code>: 变更之前的页码状态对象。</li>
</ul><p>通过初始化选项监听：</p><pre class="prettyprint prettyprinted" style=""><code><span class="pln">$</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">pager</span><span class="pun">({</span><span class="pln">
    onPageChange</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">state</span><span class="pun">,</span><span class="pln"> oldState</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">state</span><span class="pun">.</span><span class="pln">page </span><span class="pun">!==</span><span class="pln"> oldState</span><span class="pun">.</span><span class="pln">page</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="str">'页码从'</span><span class="pun">,</span><span class="pln"> oldState</span><span class="pun">.</span><span class="pln">page</span><span class="pun">,</span><span class="pln"> </span><span class="str">'变更为'</span><span class="pun">,</span><span class="pln"> state</span><span class="pun">.</span><span class="pln">page</span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span></code></pre><p>通过 jQuery 事件绑定监听：</p><pre class="prettyprint prettyprinted" style=""><code><span class="pln">$</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">on</span><span class="pun">(</span><span class="str">'onPageChange'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">e</span><span class="pun">,</span><span class="pln"> state</span><span class="pun">,</span><span class="pln"> oldState</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">state</span><span class="pun">.</span><span class="pln">page </span><span class="pun">!==</span><span class="pln"> oldState</span><span class="pun">.</span><span class="pln">page</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="str">'页码从'</span><span class="pun">,</span><span class="pln"> oldState</span><span class="pun">.</span><span class="pln">page</span><span class="pun">,</span><span class="pln"> </span><span class="str">'变更为'</span><span class="pun">,</span><span class="pln"> state</span><span class="pun">.</span><span class="pln">page</span><span class="pun">);</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span></code></pre></article></section>














<section><header><h3>自定义</h3></header><article><p>通过 <code>linkCreator</code> 选项指定一个字符串模板或者回调函数来生成页码上的链接。</p><pre class="prettyprint prettyprinted" style=""><code class="lang-html"><span class="com">&lt;!-- 如果总条目数目为 10，第一页的链接将为 mypage.html?page=1&amp;totalCount=10 --&gt;</span><span class="pln">
</span><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">data-ride</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"89"</span><span class="pln"> </span><span class="atn">data-link-creator</span><span class="pun">=</span><span class="atv">"mypage.html?page={page}&amp;totalCount={recTotal}"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="com">// 或者使用函数来动态返回链接</span><span class="pln">
$</span><span class="pun">(</span><span class="str">'#myPagerExample'</span><span class="pun">).</span><span class="pln">pager</span><span class="pun">({</span><span class="pln">
    linkCreator</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">page</span><span class="pun">,</span><span class="pln"> pager</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> </span><span class="str">'mypage.html?page='</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> page </span><span class="pun">+</span><span class="pln"> </span><span class="str">'&amp;totalCount='</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> pager</span><span class="pun">.</span><span class="pln">recTotal</span><span class="pun">;</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span></code></pre><p>通过使用 <code>elementCreator</code> 选项指定一个元素构造器用于创建自定义分页器界面组件元素。</p><p><code>elementCreator</code> 可以指定一个回调函数用于动态创建界面元素。此回调函数 <code>this</code> 指向分页器实例对象本身，参数定义如下：</p><ul>
<li><code>element</code>: 当前要创建的界面元素名称，例如 <code>'page_text'</code>；</li>
<li><code>$pager</code>: 分页器根节点元素，可以通过调用  <code>$pager.append(elementContent)</code> 来插入内容；</li>
<li><code>state</code>: 当前分页器页码信息对象。</li>
</ul><p>在元素构造函数内返回 <code>false</code> 可以继续使用默认的构造方式。</p><div class="example">
  <ul id="myCustomPagerExample" class="pager" data-page="2" data-rec-total="89" data-elements="red_page_button,total_page_text"><li><button class="btn btn-danger" type="button">2</button></li><li><div class="pager-label">共 <strong>9</strong> 页</div></li></ul>
</div><pre class="prettyprint prettyprinted" style=""><code class="lang-html"><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"myCustomPagerExample"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"pager"</span><span class="pln"> </span><span class="atn">data-page</span><span class="pun">=</span><span class="atv">"2"</span><span class="pln"> </span><span class="atn">data-rec-total</span><span class="pun">=</span><span class="atv">"89"</span><span class="pln"> </span><span class="atn">data-elements</span><span class="pun">=</span><span class="atv">"red_page_button,total_page_text"</span><span class="tag">&gt;&lt;/ul&gt;</span></code></pre><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="pln">$</span><span class="pun">(</span><span class="str">'#myCustomPagerExample'</span><span class="pun">).</span><span class="pln">pager</span><span class="pun">({</span><span class="pln">
    elementCreator</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">element</span><span class="pun">,</span><span class="pln"> $pager</span><span class="pun">,</span><span class="pln"> state</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">element </span><span class="pun">===</span><span class="pln"> </span><span class="str">'red_page_button'</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> $</span><span class="pun">(</span><span class="str">'&lt;button class="btn btn-danger" type="button"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> state</span><span class="pun">.</span><span class="pln">page </span><span class="pun">+</span><span class="pln"> </span><span class="str">'&lt;/button&gt;'</span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span></code></pre><p><code>elementCreator</code> 还可以指定为一个对象，对象的每个键名对应一个需要自定义的界面元素名称，键值为对应的元素构造器函数。</p><p>例如以上的形式使用对象格式则可以使用如下的代码实现：</p><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="pln">$</span><span class="pun">(</span><span class="str">'#myPageExample'</span><span class="pun">).</span><span class="pln">page</span><span class="pun">({</span><span class="pln">
    elementCreator</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        red_page_button</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">element</span><span class="pun">,</span><span class="pln"> $pager</span><span class="pun">,</span><span class="pln"> state</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> $</span><span class="pun">(</span><span class="str">'&lt;button class="btn btn-danger" type="button"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> state</span><span class="pun">.</span><span class="pln">page </span><span class="pun">+</span><span class="pln"> </span><span class="str">'&lt;/button&gt;'</span><span class="pun">);</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">})</span></code></pre></article></section>







<script>
function afterPageLoad() {
    $('#pageBody [data-ride="pager"]').pager().on('onPageChange', function(e, state, oldState) {
    if (state.page !== oldState.page) {
        console.log('页码从', oldState.page, '变更为', state.page);
    }
});;

    $('#myCustomPagerExample').pager({
        elementCreator: function(element, $pager, state) {
            if (element === 'red_page_button') {
                return $('<button class="btn btn-danger" type="button">' + state.page + '</button>');
            }
            return false;
        }
    });
}
</script><section><header><h3>动态更新</h3></header><article><p>除了用户点击或操作界面元素可以更改页码状态，还可以通过分页器的实例方法 <code>set(page, recTotal, recPerPage)</code> 在程序中手动更新界面元素。</p><p>该方法各参数定义如下：</p><ul>
<li><code>page</code>: 设置新的页码，如果不更改当前页码，可以传递 <code>null</code> 作为参数的值；</li>
<li><code>recTotal</code>: 设置新记录总数，如果不更改记录总数，可以传递 <code>null</code> 作为参数的值；</li>
<li><code>recPerPage</code>: 设置新的每页记录数目，如果不更改每页记录数目，可以传递 <code>null</code> 作为参数的值；</li>
</ul><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="com">// 获取分页器实例对象</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> myPager </span><span class="pun">=</span><span class="pln"> $</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">data</span><span class="pun">(</span><span class="str">'zui.pager'</span><span class="pun">);</span><span class="pln">

</span><span class="com">// 设置当前页码为 2</span><span class="pln">
myPager</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="lit">2</span><span class="pun">);</span><span class="pln">

</span><span class="com">// 设置当前页码为 3，并设置每页记录数目为 20</span><span class="pln">
myPager</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="lit">3</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> </span><span class="lit">20</span><span class="pun">);</span><span class="pln">

</span><span class="com">// 设置当前页码为 4，并同时设置记录总数为 100， 每页记录数目为 30</span><span class="pln">
myPager</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="lit">4</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">,</span><span class="pln"> </span><span class="lit">30</span><span class="pun">);</span></code></pre><p>改方法还有一种简便形式为 <code>set(newState)</code>，参数 <code>newState</code> 为一个对象，可以在对象中指定需要设置的属性值。</p><pre class="prettyprint prettyprinted" style=""><code class="lang-js"><span class="com">// 获取分页器实例对象</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> myPager </span><span class="pun">=</span><span class="pln"> $</span><span class="pun">(</span><span class="str">'#myPager'</span><span class="pun">).</span><span class="pln">data</span><span class="pun">(</span><span class="str">'zui.pager'</span><span class="pun">);</span><span class="pln">

</span><span class="com">// 设置当前页码为 4，并同时设置记录总数为 100， 每页记录数目为 30</span><span class="pln">
myPager</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">({</span><span class="pln">
    page</span><span class="pun">:</span><span class="pln"> </span><span class="lit">4</span><span class="pun">,</span><span class="pln">
    recTotal</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100</span><span class="pun">,</span><span class="pln">
    recPerPage</span><span class="pun">:</span><span class="pln"> </span><span class="lit">30</span><span class="pln">
</span><span class="pun">});</span></code></pre><p><style>
.table .pager {margin: 0;}</p>
<p>#pagerPreviewTable td {vertical-align: middle;}
</style></p></article></section></div>
</section>
{/block}